package com.chat.entry.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum MessageType {
    TEXT(1, "文字"),
    EMOJI(2, "emoji表情"),
    IMAGE(3, "图片"),
    VIDEO(4, "视频");

    @EnumValue
    private final Integer type;
    private final String description;

    MessageType(Integer type, String description) {
        this.type = type;
        this.description = description;
    }

    @JsonCreator
    public static MessageType fromValue(Integer type) {
        for (MessageType mt : values()) {
            if (mt.type.equals(type)) {
                return mt;
            }
        }
        return null;
    }

    @JsonValue
    public Integer getValue() {
        return type;
    }
}
